/*============================================================================*/
/*                   CONTINENTAL AUTOMOTIVE SYSTEMS                           */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* name:            MALPIT_Init.h
* version:         1.1
* created_by:      Lizette Acosta/Rodrigo Casados
* date_created:    June 22 2013
*=============================================================================*/
/* DESCRIPTION : In
/**
\file       PIT.h
\brief      Periodic Interrupt Timer initialization and low-level functions and prototypes
\author     Abraham Tezmol
\version    1.0
\date       03/May/2013
*/
/*******************************************************************************
/****************************************************************************************************/

#ifndef MALPIT_INIT_H        /*prevent duplicated includes*/
#define MALPIT_INIT_H

#define DSPI_5    (*(volatile struct DSPI_tag *)      0xFFFA4000UL)
#define EDMA      (*(volatile struct EDMA_tag *)      0xFFF44000UL) 
#define EMIOS_0   (*(volatile struct EMIOS_tag *)     0xC3FA0000UL)
#define EMIOS_1   (*(volatile struct EMIOS_tag *)     0xC3FA4000UL)
#define I2C_0     (*(volatile struct I2C_tag *)       0xFFE30000UL)
#define INTC      (*(volatile struct INTC_tag *)      0xFFF48000UL)
#define ECSM      (*(volatile struct ECSM_tag *)      0xFFF40000UL)
#define ME        (*(volatile struct ME_tag *)        0xC3FDC000UL)
#define MPU       (*(volatile struct MPU_tag *)       0xFFF10000UL)
#define PCU       (*(volatile struct PCU_tag *)       0xC3FE8000UL)
#define PIT       (*(volatile struct PIT_tag *)       0xC3FF0000UL)
#define RGM       (*(volatile struct RGM_tag *)       0xC3FE4000UL)
#define RTC       (*(volatile struct RTC_tag *)       0xC3FEC000UL)
#define SIU       (*(volatile struct SIU_tag *)       0xC3F90000UL)
#define SSCM      (*(volatile struct SSCM_tag *)      0xC3FD8000UL)
#define STM       (*(volatile struct STM_tag *)       0xFFF3C000UL)
#define SWT       (*(volatile struct SWT_tag *)       0xFFF38000UL)
#define WKUP      (*(volatile struct WKUP_tag *)      0xC3F94000UL)

/*****************************************************************************************************
/* Include files
*****************************************************************************************************/

/** Core Modules */
/** Variable types and common definitions */
    #include    "typedefs.h"

/** Used Modules */

/*****************************************************************************************************
* Declaration of module wide TYPES
*****************************************************************************************************/

/*****************************************************************************************************
* Definition of  VARIABLEs - 
*****************************************************************************************************/
	

/*****************************************************************************************************
* Definition of module wide MACROS / #DEFINE-CONSTANTS 
*****************************************************************************************************/

/** Periodic Interrupt Timer definitions */
#define    PIT_CHANNEL_0					0

#define    PIT_DEVICE_FREQUENCY           (uint32_t)64000000
#define    PIT_CHANNEL_TARGET_FREQUENCY   (uint32_t)2000

/** Periodic Interrupt Timer macros */
#define    PIT_CHANNEL_VALUE            	( ( PIT_DEVICE_FREQUENCY / PIT_CHANNEL_TARGET_FREQUENCY ) - 1 )


/*****************************************************************************************************
* Declaration of module wide FUNCTIONS
*****************************************************************************************************/

/** PIT Low level initialization */
void PIT_device_init(void);

/** PIT Low level Start procedure */
void PIT_channel_start(uint8_t channel);

/** PIT Low level Stop procedure */
void PIT_channel_stop(uint8_t channel);

/** PIT Channel 0 ISR  */
void PIT_channel_0_isr( void  );


/*******************************************************************************/


void PIT_channel_0_isr(void);
void enableIrq(void):
void initModesAndClock(void);
void disableWatchdog(void);


#endif /* __PIT_H */
